/*
 * A CORBA Generic Server
 * Part of the GICOM project
 */
package gicom.transaction;



import gicom.PersistentObject;
import java.util.concurrent.Semaphore;

/**
 * Abstract implementation of a recoverable object
 */
public abstract class RecoverableObject extends  PersistentObject {

    /**
     * 
     */
    private Semaphore inTransaction;

    public boolean prepare() throws gicom.generated.bankServices.ConcurrencyControlException{
	try {
	    inTransaction.acquire();
	    return true;
	} catch (InterruptedException e) {
	    throw new gicom.generated.bankServices.ConcurrencyControlException("Concurency exception while acquiring the recoverable object to a transaction : "
		    + e.getMessage());
	}
    }

    public boolean free() throws gicom.generated.bankServices.ConcurrencyControlException{
	try {
	    inTransaction.release();
	    return true;
	} catch (Exception e) {
	    throw new gicom.generated.bankServices.ConcurrencyControlException("Concurency exception while freeing the recoverable object to a transaction : "
		    + e.getMessage());
	}
    }
}
